package com.sky.controller.user;

import com.sky.entity.Dish;
import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.vo.DishVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userDishController")
@Slf4j
@RequestMapping("/user/dish")
@Api(tags = "用户端-菜品管理")
@RequiredArgsConstructor
public class DishController {
    private final DishService dishService;

    /**
     * 根据分类id查询菜品，包含口味信息
     *
     * @param categoryId
     * @return
     */
    @ApiOperation(value = "根据分类id查询菜品，包含口味信息")
    @ApiImplicitParam(name = "categoryId", value = "分类ID", required = true, dataType = "Long")
    @GetMapping("/list")
    public Result<List<DishVO>> list(Long categoryId) {
        log.info("根据分类id查询菜品，包含口味信息，categoryId：{}", categoryId);
        List<DishVO> list = dishService.listWithFlavor(categoryId);
        return Result.success(list);
    }
}
